Complete Release 3#38
Conversation
|
@lnestor cool! i'm loving the early specs and TDD approach by the way. |
|
@jaybobo I've done all the main tasks, so I'm tagging you. I'll go ahead and work on the extra credit part. |
source/app/views/urls/index.html.erb
Outdated
|
|
||
| <ul> | ||
| <% @urls.each do |url| %> | ||
| <li><%= "0.0.0.0:3000/urls/#{url.id} ====> #{url.long_url} (clicked #{url.click_count} times)" %></li> |
There was a problem hiding this comment.
Your routes file has a :urls resource with a :show action, so it should generate route helper methods for you. The name of it is kinda unfortunate in this case:
I think url_url(url) should output something like "0.0.0.0:3000/urls/#{url.id}" here. (and will remain correct in non-development environments)
|
I don't see implementation for these URL validations yet:
|
source/app/models/url.rb
Outdated
| private | ||
|
|
||
| def reset_click_count | ||
| self.click_count = 0 |
There was a problem hiding this comment.
If the migration put a default of zero in the db, ActiveRecord would respect that when you make new instances of this class.
source/app/models/url.rb
Outdated
|
|
||
| def long_url_is_reachable | ||
| begin | ||
| response = HTTParty.get(long_url, timeout: 2) |
There was a problem hiding this comment.
default timeout == ain't nobody got time for that 👍
source/app/models/url.rb
Outdated
| class Url < ActiveRecord::Base | ||
| before_create :reset_click_count | ||
|
|
||
| validates :long_url, presence: true, format: { with: /http(|s):\/\/.+/ } |
There was a problem hiding this comment.
I could nitpick this format regexp, but I'm not sure if it is needed. Is the URI::regexp matching sufficient?
There was a problem hiding this comment.
You're right - this is leftover from before I implemented the URI matching.
@jaybobo I haven't completed all parts, but I figured I'll commit each time I finish a step. I'll ping you when it is completely done too.